#!/bin/sh -e
if [ -f /tmp/adnew.conf ]; then
  if (grep -wq "address=" /tmp/adnew.conf) ; then
    cp /tmp/adnew.conf /tmp/ad.conf
  elif (grep -wq "0.0.0.0" /tmp/adnew.conf) ; then
    cp /tmp/adnew.conf /tmp/ad.conf
  else
    cat /tmp/adnew.conf | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' > /tmp/ad.conf
  fi
fi
rm -f /tmp/adnew.conf
